package com.ldq.imooc.servlet;

import com.ldq.imooc.service.ListService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @Author : 李道泉
 * @Description :
 * @Date : 2018/8/7 15:38
 * @Modified by :
 */
public class ListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //设置编码
        req.setCharacterEncoding("UTF-8");
        //接收参数
        String command = req.getParameter("command");
        String description = req.getParameter("description");
        //页面回传值
        req.setAttribute("command", command);
        req.setAttribute("description", description);
        ListService listService = new ListService();
        //查询消息列表传回页面
        req.setAttribute("messageList", listService.queryMessageList(command, description));
        //跳转页面
        req.getRequestDispatcher("WEB-INF/jsp/back/list.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
